<div class="products" style="width: 862px;">
<?php 
    $product_name = $this->_global->_unserialize($posts->product_name);
    if(isset($product_name[$this->session->userdata('lan')]))
        $product_name = $product_name[$this->session->userdata('lan')]['product_name'];
    else
        $product_name ='';
    $product_desc = $this->_global->_unserialize($posts->product_desc);
    if(isset($product_desc[$this->session->userdata('lan')]))
        $product_desc = $product_desc[$this->session->userdata('lan')]['product_desc'];
    else
        $product_desc ='';
    $product_detail = $this->_global->_unserialize($posts->product_detail);
    if(isset($product_detail['options']))
        $product_detail = $product_detail['options'];
    else
        $product_detail ='';
    $user_url = '';
    if($this->tank_auth->is_logged_in()){
        $user_url = '-'.$this->tank_auth->get_user_id();
    }

?>

<div class="l_detail">
    Loading...
</div>
<div style="" class="r_detail">
    <div class="cat-title" style="margin-bottom: 5px;"><h1><?php echo $product_name?></h1><div style="float: right;margin-top: -20px;" class="addthis_toolbox addthis_default_style clear">
<a class="addthis_button_preferred_1"></a>
<a class="addthis_button_preferred_2"></a>
<a class="addthis_button_preferred_3"></a>
<a class="addthis_button_preferred_4"></a>
<a class="addthis_button_compact"></a>
<a class="addthis_counter addthis_bubble_style"></a>
</div> </div>
    
    <div>
    		
		<form id="ratings" method="post">
			<input type="radio" name="rate" value="1" <?php if($rate == 1) echo 'checked=checked'; ?> title="Poor" id="rate1" />
			<input type="radio" name="rate" value="2" <?php if($rate == 2) echo 'checked=checked'; ?> title="Fair" id="rate2" />
			<input type="radio" name="rate" value="3" <?php if($rate == 3) echo 'checked=checked'; ?> title="Average" id="rate3" /> 
			<input type="radio" name="rate" value="4" <?php if($rate == 4) echo 'checked=checked'; ?> title="Good" id="rate4" /> 
			<input type="radio" name="rate" value="5" <?php if($rate == 5) echo 'checked=checked'; ?> title="Excellent" id="rate5" /> 
            <label for="rate5" style="padding: 0 5px;font-weight: bold;">(<?php echo $rate ?>/5)</label><label for="rate5" style="padding: 0 5px;font-weight: bold;" id="msg"></label>
           
		</form>
        <div class="clear"></div>
    </div>
    <p><strong>Thông tin bảo hàng sản phẩm </strong> : </p>
    <p><?php echo $posts->price_import; ?></p>
    <?php echo form_open('index/shop/addToCart') ?>
    <div style="padding: 10px;background: #f6f6f6;margin-top: 10px;">
        <table width="100%">
            <tr>
                <td width="48%">
                <p><?php echo $this->lang->line('choose_size') ?></p>
        <select  class="size">
        <?php echo _size(); ?>
        </select>
        <div class="clear"></div>
        <p><?php echo $this->lang->line('choose_color') ?></p>
        <select id="colors" name="colors" style="border: 1px solid #ccc;width: 200px;padding: 3px;margin-top: 5px;" id="colors">
            <?php 
                $colors =  explode(',',$posts->color_tag);
                if(!empty($colors)){
                    foreach($colors as $color){
                        echo '<option value='._set_alias($color).'>'.$color.'</option>';
                    }
                }
            ?>
        </select>
        <p style="padding: 5px 0;"><?php echo $this->lang->line('qty') ?>:<input type="text" name="qty" id="qty" value="1" style="width: 30px;padding: 5px;" /></p>
        
        <input type="hidden" name="product_id" id="product_id" value="<?php echo $posts->product_id ?>" />
        <input type="hidden" name="_size" id="_size" />
        <input type="hidden" name="max_qty" id="max_qty" />
        <input type="hidden" name="price" id="price" value="<?php echo $posts->price_export ?>" />
        <input type="hidden" name="c_name" id="c_name" value="<?php echo $product_name ?>" />
        <input type="hidden" name="link" id="link" value="<?php echo $this->uri->uri_string() ?>" />
                </td>
                <td width="300" align="left" style="position: relative;">
                <?php if($posts->price_discount>0){
                    echo '<p  class="cost"><strike>'.$posts->price_export.' vnd</strike> '.$posts->price_discount.' vnd</p>';
                }else{
                        echo '<p class="cost">'.$posts->price_export.'vnd</p>';
                }?>
                
                <div class="cart-button2" style="margin-top: 15px;width: 150px;position: relative;left: 110px;top:00px"><span><a style="color: #fff;" href="javascript:;" id="addtocart">Thêm vào giỏ hàng</a></span></div>
               <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=harry88pham"></script>

                <!-- AddThis Button BEGIN -->
<!-- AddThis Button END -->

                </td>
            </tr>
            <tr>
                <td colspan="2"><?php if($this->tank_auth->is_logged_in()): ?>
        <p>Chia sẽ : <input type="text" style="width: 425px;height: 25px;" value="<?php echo site_url().$this->uri->uri_string().'/'.$this->tank_auth->get_user_id().'.html'?>"/></p>
        <?php endif; ?></td>
            </tr>
        </table>
        
        
    </div></form>
    
</div>
<div class="clear"></div>

</div>
<div class="clear"></div>

<div class="main">
<div class="cat-title"><h2>Mô tả sản phẩm</h2></div>
<p><?php echo $product_desc?></p>
</div>
<div class="main">
<div class="cat-title"><h2><?php echo $this->lang->line('comment_title') ?></h2></div>
    <div id="cm">
    <div class="jScrollbar4">
	<div class="jScrollbar_mask">
		<?php  echo _get_comments() ?>
	</div>
	
	<div class="jScrollbar_draggable">
		<a href="#" class="draggable"></a>
	</div>

		
	<div class="clr"></div>
</div>

<div style="clear:both"></div>
        
    </div>
    <div style="float: left;width: 500px;">
    <form method="post" style="border: 1px dotted #ccc;">
        <table width="100%">
        <tr><td width="25%" style="padding: 5px;"><b>Họ và tên</b></td>  
                <td style="padding: 5px;"><input type="text" name="name" id="name" style="width: 350px;height: 26px;" /></td>
            </tr>
        <tr><td width="22%" style="padding: 5px;"><b><?php echo $this->lang->line('comment_email') ?></b></td>  
                <td style="padding: 5px;"><input type="text" name="email" id="email" style="width: 350px;height: 26px;" /></td>
            </tr>
        </table>
        <table width="100%">
            
            <tr>  
                <td style="padding: 5px;"><b>Nội dung chi tiết</b><textarea name="content" id="ct" style="width: 475px;height: 100px;" ></textarea></td>
            
            </tr>
            <tr><td style="padding: 5px ;text-align: left;vertical-align: top;">
            <?php echo _create_recaptcha(); ?>
            <div class="button" style="position: static;width: 80px;"><span><a href="javascript:;" id="submit"><?php echo $this->lang->line('comment_send') ?></a></span></div></td></tr>            
        </table>
    </form></div>
    <div style="float: right;width: 350px;min-height: 250px;"><?php $banners = _get_banners($this->uri->rsegment(3),1) ;
        if(!empty($banners)){
            
        }else
        {
        echo '<img src="'.$this->config->item('cdn_url').'images/ads.gif" />';    
        }
    ?></div>
    <div class="clear"></div>
</div>
<div class="main">
<div class="cat-title"><h2><?php echo $this->lang->line('relative_product') ?></h2></div>
<?php 
$relate_products = _get_related_products();
if(!empty($relate_products)):
?>

<?php 
$i=0;

foreach($relate_products as $post): 
if($i>0 && $i%4==0)
    $last = 'last';
else
    $last='';
    $product_name = $this->_global->_unserialize($post->product_name);
    $alias = $this->_global->_unserialize($post->product_alias);
    if(isset($alias[$this->session->userdata('lan')]['alias']))
        $alias = $alias[$this->session->userdata('lan')]['alias'];
    else
        $alias = '';
    
    if(isset($product_name[$this->session->userdata('lan')]['product_name']))
        $product_name = $product_name[$this->session->userdata('lan')]['product_name'];
    else
        $product_name = '';
    
    $detail = $this->_global->_unserialize($post->product_detail);
    if(is_array($detail))
        $color =current($detail['options']['colors']);
    else
        $color=array('images'=>array('0'));
?>
<div class="item">
            <div class="price-button"><?php echo $post->price_export?> vnd</div>
                	<?php echo anchor('shop/c'.$post->cat_id.'/'.$alias.'-'.$post->product_id,'<img alt="'.$product_name.'" src="'.$this->config->item('cdn_url').'exec/timthumb.php?src='.base_url().current($color['images']).'&w=175&h=175&zc=1"/>','title="'.$product_name.'"') ?>
                    <h3><?php echo anchor('shop/c'.$post->cat_id.'/'.$alias.'-'.$post->product_id,$product_name) ?></h3>
                    <div class="button"><span><?php echo anchor('shop/c'.$post->cat_id.'/'.$alias.'-'.$post->product_id,'Xem chi tiết')?></span></div>
            </div>

<?php 

endforeach; ?>

<?php
else:
?>
<div><h1 class="title"><?php echo $this->lang->line('notfound') ?></h1></div>
<?php
endif;
?>
<?php echo '<script type="text/javascript"> var options = '.json_encode($product_detail).';</script>'; 
unset($posts);
?>
<div class="clear"></div>
</div>